package com.unknownman.block.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.lianziyou.chain.common.api.CommonPage;
import com.lianziyou.chain.common.api.CommonResult;
import com.unknownman.block.constants.ChainContractConstants;
import com.unknownman.block.dto.ChainContractComposition;
import com.unknownman.block.entity.TChainConfig;
import org.cloud.exception.BusinessException;

import java.util.List;


/**
* <p>
    * NFT链配置 服务类
    * </p>
*
* @author xhy
* @since 2021-10-16
*/
public interface TChainConfigService extends IService<TChainConfig> {
    /**
    * 查询NFT链配置分页数据
    *
    * @param page      页码
    * @param limit 每页条数
    * @return CommonResult<TChainConfig>
    */
    CommonPage<TChainConfig> findListByPage(Integer page, Integer limit, String orderBy, QueryWrapper<TChainConfig> queryWrapper);

    /**
     * 获取链合约复合对象
     * @param onlyEnable 是否仅查询启用的数据
     * @return
     */
    public List<ChainContractComposition> getChainContractCompositionList(boolean onlyEnable);

    /**
     * 根据链状态获取列表
     * @param chainStatus
     * @return
     */
    public List<TChainConfig> getListByStatus(ChainContractConstants.ChainStatusConstants chainStatus);

    /**
     *根据id获取复合对象
     * @param id
     * @return
     */
    public ChainContractComposition getChainContractCompositionById(Long id);


    /**
     * 根据链符号获取链合约复合对象
     * @param symbol
     * @return
     */
    public ChainContractComposition getChainContractCompositionByChainSymbol(String symbol);

    /**
     * 更新最后区块
     * @param id
     * @param block
     * @return
     */
    public int updateLastBlock(Long id, Long block, boolean success);

    CommonResult updateChain(TChainConfig config) throws BusinessException;

    CommonResult addChain(TChainConfig config) throws BusinessException;

    CommonResult updateStatus(Long chainConfigId, Integer status) throws BusinessException;
}
